#!/bin/sh -e

K_VERSION=7.1.248

if [ `id -u` -ne 0 ]; then
  echo "$0: error: This script must be run as root."
  exit 1
fi
TAG=`git describe HEAD --tags`
. /etc/os-release
case $ID in
	ubuntu)
		CODENAME=$UBUNTU_CODENAME
		case $CODENAME in
			jammy)
				;;
			*)
				echo "Unsupported Ubuntu version, try building from source."
				exit 1
				;;
		esac
		;;
	*)
		echo "Unsupported Linux distro, try building from source."
		exit 1
		;;
esac

apt-get update
apt-get install -y curl
curl -L https://github.com/runtimeverification/k/releases/download/$TAG/kframework_${K_VERSION}_amd64_$CODENAME.deb -o kframework_${K_VERSION}_amd64.deb
apt-get install -y ./kframework_${K_VERSION}_amd64.deb
rm -f kframework_${K_VERSION}_amd64.deb
